#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int maxSubArray(vector<int>& nums) {
    vector<int> res;
    res.push_back(nums[0]);
    int Max = res[0];
    for (int i = 1; i < nums.size(); i++)
    {
        if (nums[i] + res[i - 1] > nums[i])
            res.push_back(nums[i] + nums[i - 1]);
        else
            res.push_back(nums[i]);
        Max = max(Max, res[i]);
    }
    return Max;
}
int main()
{
    vector<int> cur{ -2, 1, -3, 4, -1, 2, 1, -5, 4 };
    maxSubArray(cur);
}
